<?php
    session_start();   
	$id=$_REQUEST["id"];
	$sql="SELECT * FROM product WHERE status=1 AND id=$id";
	$rs=mysql_query($sql);
	if($rs)
	{
		$row = mysql_fetch_array($rs);
	}
 ?>


<div id="content">
	<div id="chitiet1">
		<div class="imagesp"><img align="baseline" src='images/product/<?php echo $row["image"]?>' /></div>
	</div>
	
	<div id="chitiet2">
		<div id="chitiet21">
			<span class="ctten"><?php echo $row["name"]?></span>
			<p>Mã sản phẩm: <?php echo $row["code"]?></p>
			<p>Loại sản phẩm: <a href="category.php?id=<?php echo $row2["id"];?>"><?php echo $row2["name"];?></a></p>				
			<p>Giá bán: <span class="ctgia"><?php echo number_format($row["price"],0,",",".");?> VND</span></p>
			<p>Tình trạng:<span class="ctgia">Còn hàng</span></p>
            <form method="post" action="">

		<a href="product.php?cmd=add&id=<?php echo $row["id"]?>"><img src="images/cho_vao_gio.png" border="0" /></a>
<?php
if(isset($_REQUEST["cmd"]) && $_REQUEST["cmd"] == "add"){
                 
        $id=$_GET['id'];
        if(isset($_SESSION['cart'][$id]))
        {
       	 $qty = $_SESSION['cart'][$id] + 1;
        }
        else
        {
        $qty=1;
        }
        $_SESSION['cart'][$id]=$qty;
         echo ("<br/>Thêm thành công")   ;
}
?>	
                  
		</div>
		
		<div id="chitiet22">
		<a href="buy.php?id=<?php echo $id?>"><img src="images/muangay.png" border="0" /></a>
		</div>
	
	</div>
	

	
		

		<div id="tfproduct">
		<div id="tsanpham"><p class="tp">Mô tả chi tiết</p></div>	
		<div class="description"><span><?php echo $row["description"]?> </span></div>
		
		
<div id="tsanpham"><p class="tp">Sản phẩm cùng loại</p></div>

<?php 
$sql3="SELECT * FROM product WHERE subcategory=" .$row["subcategory"]. " AND id<>$id ORDER By id desc LIMIT 0,4";
//echo "[$sql3]";
$rs3=mysql_query($sql3);
	if($rs3) 
	{
		while($row3=mysql_fetch_array($rs3)) 
		{
?>
			<div class="sanpham"><a href="product.php?id=<?php echo $row3["id"];?>"><img class="img" src="images/product/<?php echo $row3["image"];?>" border="0"/></a>
			<span><?php echo $row3["name"]; ?></span>
			<p>Mã SP: <?php echo $row3["code"]; ?></p>
			<p class="gia"><?php echo $row3["price"]; ?></p>
			<a href="buy.php?id=<?php echo $row3["id"];?>"><img src="images/buy.png" boder="0"/></a>
			</div>
									
<?php
 		} 
	} 
?>
	</div>
</div>